package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.Basis;
import com.indusfo.spc.service.BasisService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ProjectName: jpa05
 * @Package: com.indusfo.spc.controller
 * @ClassName: BasisController
 * @Author: 熊冰
 * @Description: 工艺文件库 控制层
 * @Date: 2019/9/25 9:07
 * @Version: 1.0
 */
@Controller
@RequestMapping("/basis")
public class BasisController {

	/**
	 * 注入service
	 */
	@Autowired
	BasisService basisService;

	//新增
	@RequestMapping("/insertBasis")
	@ResponseBody
	public JSONObject insertBasis(Basis basis) {
		JSONObject json = basisService.insertBasis(basis);
		return json;
	}


	//删除
	@RequestMapping("/deleteBasis")
	@ResponseBody
	public JSONObject deleteBasis(@RequestParam("lBasisIds") List<Integer> lBasisIds) {
		// 将删除常量放入
		JSONObject json = basisService.deleteBasis(lBasisIds, 2);
		return json;
	}

	//启用停用
	@RequestMapping("/definesBasis")
	@ResponseBody
	public JSONObject definesBasis(@RequestParam("lBasisIds") List<Integer> lBasisIds, Integer lDataState) {
		JSONObject json = basisService.deleteBasis(lBasisIds, lDataState);
		return json;
	}

	//修改
	@RequestMapping("/updateBasis")
	@ResponseBody
	public JSONObject updateBasis(Basis basis) {
		JSONObject json = basisService.updateBasis(basis);
		return json;
	}

	//查询
	@RequestMapping("/queryBasis")
	@ResponseBody
	public JSONObject queryBasis(Basis basis) {
		JSONObject json = basisService.queryBasis(basis);
		return json;
	}

	//校检相关参数是否重复
	@RequestMapping("/checkParamsNotRepeat")
	@ResponseBody
	public JSONObject checkParamsNotRepeat(Basis basis) {
		JSONObject json = basisService.checkParamsNotRepeat(basis);
		return json;
	}

	//新增
	@RequestMapping("/insertOrUpdateBasis")
	@ResponseBody
	public JSONObject insertOrUpdateBasis(@RequestBody Basis basis) {
		JSONObject json = basisService.insertOrUpdateBasis(basis);
		return json;
	}
}








